#include("./layout.html")
#include("_sidebar.html")
#include("_include.html")

#@layout()

#define script()
#@sidebarResource()
#end

#define css()
#@articleListIncludeCss()
#end

#define content()
<div class="col-md-8 col-lg-8 col-xl-9 #(option('whimurmur_sidebar_position') == 'left' ? 'offset-md-4 offset-lg-4 offset-xl-3 cl-right' : 'cl-left')">
    #set(topArticle={})
    #set(classify=org.apache.commons.lang3.StringUtils::substring(C.request.servletPath, org.apache.commons.lang3.StringUtils::lastIndexOf(C.request.servletPath, '/') + 1))
    #articlesEx(flag=classify + "-top", count=5, hiddenFlag=true,orderBy='article.modified desc')
    #for(article : articles)
        #set(topArticle[''+article.id] = 'top')
        <div class="cl-card pr">
            <a class="card-link" href="#(article.url)" target="#(option('whimurmur_link_to_blank') && article.linkTo ? '_blank' : '_self')">
                <div class="row">
                    <div class="col-lg-3 col-md-4 col-sm-12 cl-card-image">
                        <img src="#(article.thumbnail ? article.thumbnail : (article.showImage ? article.showImage : 'img/default-img.png'))" class="img-fluid" alt="">
                    </div>
    
                    <div class="col-lg-9 col-md-8 col-sm-12 cl-card-main bg-light">
                        <h3 class="cl-card-main-title">
                           #(article.title)
                        </h3>
                        <p class="cl-card-main-info">#maxLength(article.text,100)</p>
                        <p class="cl-card-more">#(article.user.nickname ??) 发布于 #date(article.created ?? article.modified, "yyyy年MM月dd日 HH时")
                            #articleCategories(article.getId(), 'category')
                                &nbsp;|&nbsp;分类：
                                #for(category: categories)
                                    #(category.title ??)
                                #end
                            #end
                            #articleCategories(article.getId(), 'tag')
                                &nbsp;|&nbsp;标签：
                                #for(category: categories)
                                    #(category.title ??)
                                    #if(for.size != for.count)
                                        &nbsp;/&nbsp;
                                    #end
                                #end
                            #end
                        </p>
                    </div>
                </div>
            </a>
            <h3><span class="card-top-flag badge badge-success">置顶</span></h3>
        </div>
    #end
    #end
    
    #set(req=C.request)
    #set(pageParams={'year':req.getAttribute('year'),'month':req.getAttribute('month'), 'addition': req.getAttribute('addition')})
    #articlePageEx(pageSize=java.lang.Integer::parseInt(option('whimurmur_list_size', 15)), hiddenFlag=true, year=pageParams['year'], month=pageParams['month'], addition=pageParams['addition'],orderBy='article.modified desc')
        #for(article : articlePageEx.list)
        #if(!topArticle[''+article.id])
        <div class="cl-card bg-light">
            <a class="card-link" href="#(article.url)" target="#(option('whimurmur_link_to_blank') && article.linkTo ? '_blank' : '_self')">
                <div class="row">
                    <div class="col-lg-3 col-md-4 col-sm-12 cl-card-image">
                        <img src="#(article.thumbnail ? article.thumbnail : (article.showImage ? article.showImage : 'img/default-img.png'))" class="img-fluid" alt="">
                    </div>
    
                    <div class="col-lg-9 col-md-8 col-sm-12 cl-card-main bg-light">
                        <h3 class="cl-card-main-title">
                           #(article.title)
                        </h3>
                        <p class="cl-card-main-info">#maxLength(article.text,100)</p>
                        <p class="cl-card-more">#(article.user.nickname ??) 发布于 #date(article.created ?? article.modified, "yyyy年MM月dd日 HH时")
                            &nbsp;|&nbsp;
                            #articleCategories(article.getId(), 'category')
                                分类：
                                #for(category: categories)
                                    #(category.title ??)
                                #end
                            #end
                            &nbsp;|&nbsp;
                            #articleCategories(article.getId(), 'tag')
                                标签：
                                #for(category: categories)
                                    #(category.title ??)
                                    #if(for.size != for.count)
                                        &nbsp;/&nbsp;
                                    #end
                                #end
                            #end
                        </p>
                    </div>
                </div>
            </a>
        </div>
        #end
        #if(for.count==1 && option('whimurmur_list_ad_1' ??))
            <div class="cl-card card-link">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 cl-card-main bg-light">
                        <div class="list-1-ad" id="list-1-ad">
                            <div class="list-1-ad-main">
                                <div id="list-1-ad-content" class="m-1 ad-content">
                                    #option("whimurmur_list_ad_1" ??)
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        #else if(for.count==5 && option('whimurmur_list_ad_2' ??))
            <div class="cl-card card-link">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 cl-card-main bg-light">
                        <div class="list-2-ad" id="list-2-ad">
                            <div class="list-2-ad-main">
                                <div id="list-2-ad-content" class="m-1 ad-content">
                                    #option("whimurmur_list_ad_2" ??)
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        #else if(for.count==10 && option('whimurmur_list_ad_3' ??))
            <div class="cl-card card-link">
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 cl-card-main bg-light">
                        <div class="list-3-ad" id="list-3-ad">
                            <div class="list-3-ad-main">
                                <div id="list-3-ad-content" class="m-1 ad-content">
                                    #option("whimurmur_list_ad_3" ??)
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        #end
        #end
        
        #set(path=C.request.servletPath)
        #articlePaginateEx(firstGotoIndex=(path.substring(path.lastIndexOf('/') + 1).startsWith('index-')))
        <nav aria-label="">
            <ul class="pagination justify-content-center">
                #for(page : pages)
                <li class="page-item #(page.style)"><a class="page-link" href="#(page.url ??)">#(page.text)</a></li>
                #end
            </ul>
        </nav>
        #end
    #end

</div>

<div class="col-md-4 col-lg-4 col-xl-3 #(option('whimurmur_sidebar_position') == 'left' ? 'offset-mdn-8 offset-lgn-8 offset-xln-9 offset-smn-0 cl-left' : 'cl-right')">
    #@sidebarContent()
</div>
#end